<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      img {
        width: 300px;
      }
    </style>
  </head>
  <body>
    <button class="hg">胡歌</button>
    <button class="jjy">鞠婧祎</button>
    <br />
    <img src="./huge.jpg" alt="" />

    <script>
      //修改元素
      //1.获得2个按钮  和图片
      var hg = document.querySelector('.hg');
      var jjy = document.querySelector('.jjy');
      var img = document.querySelector('img');
      //2.给按钮绑定点击事件更换src和title属性
      hg.onclick = function () {
        //3.事件
        img.src = './huge.jpg';
      };
      jjy.onclick = function () {
        //3.事件
        img.src = './jujingyi.jpg';
        img.style.height = '400px';
      };
    </script>
  </body>
</html>
